package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.Messages;
import com.example.demo.mapper.MessagesMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/message")

public class MessagesController {
    @Resource
    MessagesMapper messagesMapper;

    @PostMapping
    public Result<?> save(@RequestBody Messages messages){
        messagesMapper.insert(messages);
        return Result.success();
    }
    @PutMapping
    public Result<?> update(@RequestBody  Messages messages){
        messagesMapper.updateById(messages);
        return Result.success();
    }
    @GetMapping
    public Messages  selectOne(@RequestParam int searchId){
        return messagesMapper.selectById(searchId);
    }

    @DeleteMapping("/{id}")
    public Result<?> update (@PathVariable Long id){
        messagesMapper.deleteById(id);
        return Result.success();
    }
}
